<template>
  <el-row class="tac">
    <el-col :span="12">
      <el-menu
        default-active="1"
        class="el-menu-vertical-demo"
        @open="handleOpen"
        @close="handleClose"
        background-color="#545c64"
        text-color="#fff"
        active-text-color="#ffd04b"
      >
        <el-menu-item index="1" style="width: 200px" @click="goHomes">
          <i class="el-icon-s-home"></i>
          <span slot="title">首页</span>
        </el-menu-item>
        <el-menu-item index="2" style="width: 200px" @click="goAdduser">
          <i class="el-icon-user-solid"></i>
          <span slot="title">新增用户</span>
        </el-menu-item>
        <el-submenu index="3">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span>试卷管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="3-1" @click="goEditStudent">查看试卷</el-menu-item>
            <el-menu-item index="3-2" @click="goAddStudent">添加试卷</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
        <el-submenu index="4">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span>试题类型管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="4-1" @click="goEditClassify">查看所有试题类型</el-menu-item>
            <el-menu-item index="4-2" @click="goAddClassify">添加试题类型</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
        <el-submenu index="5">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span>教室管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="5-1" @click="goEditClassRoom">查看所有教室</el-menu-item>
            <el-menu-item index="5-2" @click="goAddClassRoom">添加教室</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
        <el-submenu index="6">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span>学生管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="6-1" @click="goEditStu">查看学生</el-menu-item>
            <el-menu-item index="6-2" @click="goAddStu">添加学生信息</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
      </el-menu>
    </el-col>
  </el-row>
</template>

<script>
export default {
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    goHomes() {
      //
      if (this.$route.path !== "/home/homes") {
        this.$router.push("/home/homes");
      }
    },
    goAdduser() {
      //
      if (this.$route.path !== "/home/adduser") {
        this.$router.push("/home/adduser");
      }
    },
    goEditStudent() {
      //
      if (this.$route.path !== "/home/student/editstudent") {
        this.$router.push("/home/student/editstudent");
      }
    },
    goAddStudent() {
      //
      if (this.$route.path !== "/home/student/addstudent") {
        this.$router.push("/home/student/addstudent");
      }
    },
    goEditClassify() {
      //
      if (this.$route.path !== "/home/testclassify/editTestclassify") {
        this.$router.push("/home/testclassify/editTestclassify");
      }
    },
    goAddClassify() {
      //
      if (this.$route.path !== "/home/testclassify/addtestclassify") {
        this.$router.push("/home/testclassify/addtestclassify");
      }
    },
    goEditClassRoom() {
      //
      if (this.$route.path !== "/home/classroom/editclassroom") {
        this.$router.push("/home/classroom/editclassroom");
      }
    },
    goAddClassRoom() {
      //
      if (this.$route.path !== "/home/classroom/addclassroom") {
        this.$router.push("/home/classroom/addclassroom");
      }
    },
    goEditStu() {
      //
      if (this.$route.path !== "/home/stu/editstu") {
        this.$router.push("/home/stu/editstu");
      }
    },
    goAddStu() {
      //
      if (this.$route.path !== "/home/stu/addstu") {
        this.$router.push("/home/stu/addstu");
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.el-submenu {
  width: 200px;
}
.el-col-12 {
  width: 199px;
}
.el-menu {
  width: 100%;
  height: calc(100vh - 60px);
}
</style>